﻿//using System.Linq;
//using System.Security.Claims;
//using System.Threading.Tasks;
//using Microsoft.AspNet.Identity;
//using System.Collections.Generic;
//using ElCamino.AspNet.Identity.AzureTable;
//using ElCamino.AspNet.Identity.AzureTable.Model;
//using CloudStorageLight.Core.Recommender;
//using Microsoft.WindowsAzure;
//using CloudStorageLight.Core;

//namespace CloudStorageLight.SharePointWeb.Models
//{
//    // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
//    public class ApplicationUser : IdentityUser, IRecommendedUser
//    {

//        public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
//        {
//            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
//            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
//            // Add custom user claims here
//            return userIdentity;
//        }

//        private IList<string> roles { get; set; }

//        //public bool IsAdmin { get { return roles.Any(x=>x == BlobUser.AdminRoleName); } }
//        //public IEnumerable<string> Groups { get { return roles.Where(x => x != BlobUser.AdminRoleName); } }

//        public bool IsDeliverablesRecommendMail { get; set; }

//        public string PreferKeywords { get; set; }

//        public string RecommendedList { get; set; }

//        public async Task EnsureRolesAsync(UserManager<ApplicationUser> manager)
//        {
//            if (roles == null) roles = await manager.GetRolesAsync(this.Id);
//        }

//        Dictionary<string, float> IRecommendedUser.PreferKeywords
//        {
//            get
//            {
//                var result = new Dictionary<string, float>();
//                if (this.PreferKeywords == null) return null;
//                if (this.PreferKeywords == "") return new Dictionary<string,float>();
//                foreach (var keyVal in this.PreferKeywords.Split(','))
//                {
//                    var work = keyVal.Split(':');
//                    result.Add(work[0], float.Parse(work[1]));
//                }
//                return result;
//            }
//            set
//            {
//                this.PreferKeywords = string.Join(",", value.Select(x => x.Key + ":" + x.Value.ToString()));
//            }
//        }


//        List<string> IRecommendedUser.RecommendedList
//        {
//            get
//            {
//                if (this.RecommendedList == null) return null;
//                return this.RecommendedList.Split(',').Select(x => x.Trim()).Where(x=>!string.IsNullOrEmpty(x)).ToList();
//            }
//            set
//            {
//                this.RecommendedList = string.Join(",", value);
//            }
//        }
//    }



//    public class ApplicationDbContext : IdentityCloudContext<ApplicationUser>
//    {
//        public ApplicationDbContext()
//            : base(SystemSettings.Instance.BlobStorage)
//        {
//        }

//        public static ApplicationDbContext Create()
//        {
//            return new ApplicationDbContext();
//        }
//    }
//}